package com.weakteam.orderonline.dataresource.service;

import com.weakteam.orderonline.dataresource.dao.GoodsDAO;
import com.weakteam.orderonline.dataresource.dao.MenuDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

/**
 * @author Nail
 */

@Service
public class CompositeServiceImpl implements CompositeService {

    @Autowired
    private MenuDAO menuDAO;

    @Autowired
    private GoodsDAO goodsDAO;

    @Transactional
    @Override
    public HashSet<String> getAllPictureFilesList() {
        HashSet<String> result = new HashSet<String>();
        result.addAll(menuDAO.getImageFileList());
        result.addAll(menuDAO.getIcoFileList());
        result.addAll(goodsDAO.getImageFileList());
        result.addAll(goodsDAO.getIcoFileList());
        return result;
    }

    @Transactional
    @Override
    public HashSet<String> getAllEnabledPictureFilesList() {
        HashSet<String> result = new HashSet<String>();
        result.addAll(menuDAO.getEnabledImageFileList());
        result.addAll(menuDAO.getEnabledIcoFileList());
        result.addAll(goodsDAO.getEnabledImageFileList());
        result.addAll(goodsDAO.getEnabledIcoFileList());
        return result;
    }

}
